import type { CategoryDTO } from '@/types/dto/CategoryDTO'
import request from '@/utils/request'
import type { Result } from '@/types/common/Result'
import type { CategoryVO } from '@/types/vo/CategoryVO'
import type { ArticleQuery } from '@/types/query/ArticleQuery'
import type { PageResult } from '@/types/common/PageResult'
import type { ArticleVO } from '@/types/vo/ArticleVO'
import type {ArticleInfoEs} from "@/types/entity/ArticleInfoEs";

/**
 * 获取分类
 */
export const getCategoryList = (params: CategoryDTO) => {
  return request.post<Result<CategoryVO[]>>(`/article/category/list`, params)
}

/**
 * 根据id查询文章子分类及其标签
 */

export function getSubCategoryAndTag(id?: number) {
  return request.get<Result<CategoryVO[]>>(`/article/category/subTag/${id}`)
}

/**
 * 分页获取文章列表
 */
export function getArticleList(params: ArticleQuery) {
  return request.post<Result<PageResult<ArticleVO>>>(`/article/page`, params)
}

/**
 * 获取推荐文章
 */
export function getRecommendArticle() {
  return request.get<Result<ArticleVO[]>>(`/user/recommend`)
}

/**
 * 全文检索
 */
export function searchService(params: ArticleQuery){
  return request.post<Result<PageResult<ArticleInfoEs>>>(`/article/search`, params);
}
